﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Server.Model
{
    public class Station : IComparable
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int Id { get; set; }
        [Required]
        public string Name { get; set; }
        [Required]
        public string StreetAddress { get; set; }
        [Required]
        public string ZipCode { get; set; }
        [Required]
        public string City { get; set; }
        [Required]
        public double Longitude { get; set; }
        [Required]
        public double Latitude { get; set; }
        public virtual ICollection<Route> From { get; set; }
        public virtual ICollection<Route> To { get; set; }
        [NotMapped]
        public bool Marked { get; set; }
        [NotMapped]
        public double Weight { get; set; }
        [NotMapped]
        public Station Predecessor { get; set; }

        public Station()
        {
            Name = "";
            StreetAddress = "";
            ZipCode = "";
            City = "";
            Longitude = 0.0;
            Latitude = 0.0;
            Id = 0;

            Marked = false;
            Weight = double.PositiveInfinity;
            Predecessor = null;
        }

        public int CompareTo(object obj)
        {
            if (obj == null) 
            {
                return 1;
            }
            Station other = obj as Station;
            if (other != null)
            {
                return Weight.CompareTo(other.Weight);
            }
            else
            {
                throw new Exception("");
            }
        }

     
    }
}
